﻿//-----------------------------------------------------------------
//
// @(#)$Id: CountryCategoryDetail.aspx.cs,v 1.0 2013/12/13 16:56:13 lichunhua Exp $
// @(#)$Author: lichunhua  $
// @(#)$Date: 2013/12/13 16:56:13 $
// @(#)$Description:
//
//
//
//                 All Rights Reserved.
//-----------------------------------------------------------------
using System;
using ebay.Dal.CenterDB_EbayTableAdapters;
using System.Data;

public partial class UI_Bas_CountryCategoryDetail : System.Web.UI.Page
{
    static string act = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            act = Request.QueryString["act"];
            if (!string.IsNullOrEmpty(act))
            {
                switch (act)
                {
                    case "I":
                        break;
                    case "U":
                        {
                            this.txtId.Attributes["readonly"] = "readonly";
                            string Id = Request.QueryString["id"];
                            T_CountryCategoryTableAdapter ebayAdapter = new T_CountryCategoryTableAdapter();
                            DataTable dt = ebayAdapter.GetDataById(Id);
                            DataRow r = dt.Rows[0];
                            txtId.Value = r["Id"].ToString();
                            txtCountryCategory.Value = r["CountryCategory"].ToString();
                        }
                        break;
                }
            }
        }
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (Session["UserId"] == null)
        {
            WebUtility.ShowMsg("登陆超时,请重新登陆", this);
            return;
        }
        if (!string.IsNullOrEmpty(act))
        {
            switch (act)
            {
                case "I":
                    {
                        T_CountryCategoryTableAdapter ebayAdapter = new T_CountryCategoryTableAdapter();
                        int flag = ebayAdapter.IsExists(txtId.Value).Value;
                        if (flag == 0)
                        {
                            int val = ebayAdapter.Insert(txtId.Value,
                                txtCountryCategory.Value,
                                "",
                                "",
                                DateTime.Now,
                                "",
                                new DateTime(1900, 1, 1)
                                );
                            if (val > 0)
                            {
                                Response.Write("<script>alert('添加成功!');window.location.href='CountryCategory.aspx'</script>");
                            }
                        }
                        else
                        {
                            Response.Write("<script>alert('编号重复!..');</script>");
                        }
                    }
                    break;
                case "U":
                    {

                        T_CountryCategoryTableAdapter ebayAdapter = new T_CountryCategoryTableAdapter();
                        int val = ebayAdapter.Update(txtCountryCategory.Value, "", "", DateTime.Now, "", new DateTime(1900, 1, 1), txtId.Value);
                        if (val > 0)
                        {
                            Response.Write("<script>alert('修改成功!');window.location.href='CountryCategory.aspx'</script>");
                        }
                    }
                    break;
                default:
                    break;
            }
        }
    }
}
